import { defineComponent, computed } from 'vue'

import { compConfig } from '@/packages/comp-config.js'

export default defineComponent({
  name: 'CenterRender',
  props: {
    data: {
      type: Object,
      default: null
    }
  },
  setup (props) {
    const config = computed(() => {
      if (!props.data) {
        return {}
      }
      return props.data
    })
    const component = compConfig.componentMap[config.value.key]
    if (!component) {
      return () => <div>未知组件{config.value.key}</div>
    }
    return component.designer(config.value)
  }
})
